<template>
  <h2>我是Child1</h2>
  <p>count: {{ count }}</p>
</template>

<script setup>
import { onBeforeMount, onMounted, ref } from 'vue'
import emitter from '@/services/emitter'
let count = ref(0)

function increaseCount(v) {
  count.value += v
}

onMounted(() => {
  emitter.on('increase', increaseCount)
})

onBeforeMount(() => {
  emitter.off('increase', increaseCount)
})
</script>
